package com.qys.livesMall.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * @packageName:
 * @className:AsyncConfig
 * @Description:
 * @author:guomx
 * @date:2023/7/3111:55
 */
@Configuration
public class AsyncConfig implements AsyncConfigurer{
    @Override
    public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10); // 设置核心线程数
        executor.setMaxPoolSize(200); // 设置最大线程数
        executor.setQueueCapacity(200); // 设置队列容量
        executor.setThreadNamePrefix("qysAsyncThread-"); // 设置线程名称前缀
        executor.initialize(); // 初始化线程池
        return executor;
    }

}
